﻿using System.Runtime.InteropServices;

namespace Equinoxe.NFC.EasyACR122
{
    class acr122x86
    {

        #region x86

        [DllImport("acr122.dll")]
        public static extern int ACR122_OpenA(string portName, ref int phReader);

        [DllImport("acr122.dll")]
        public static extern int ACR122_OpenW(string portName, ref int phReader);

        [DllImport("acr122.dll")]
        public static extern int ACR122_GetFirmwareVersion(int phReader, int slotNum, byte[] firmwareVersion,
                                                           ref int pFirmwareVersion);

        [DllImport("acr122.dll")]
        public static extern int ACR122_Close(int phReader);

        [DllImport("acr122.dll")]
        public static extern int ACR122_DirectTransmit(int phReader, byte[] SendBuff, int SendBuffLen, byte[] RecvBuff,
                                                       ref int RecvBuffLen);

        [DllImport("acr122.dll")]
        public static extern int ACR122_GetNumSlots(int phReader, ref int pNumSlots);

        [DllImport("acr122.dll")]
        public static extern int ACR122_GetBaudRate(int phReader, ref int pBaudRate);

        [DllImport("acr122.dll")]
        public static extern int ACR122_SetBaudRate(int phReader, int baudRate);

        [DllImport("acr122.dll")]
        public static extern int ACR122_GetTimeouts(int phReader, ref acr122.ACR122_TIMEOUTS pTimeouts);

        [DllImport("acr122.dll")]
        public static extern int ACR122_SetTimeouts(int phReader, ref acr122.ACR122_TIMEOUTS pTimeouts);

        [DllImport("acr122.dll")]
        public static extern int ACR122_SetLedStatesWithBeep(int phReader, ref acr122.ACR122_LED_CONTROL[] controls,
                                                             int numControls, int t1, int t2, int numTimes,
                                                             int buzzerMode);

        [DllImport("acr122.dll")]
        public static extern int ACR122_PowerOnIcc(int phReader, int slotNum, ref byte atr, ref int pAtrLen);

        [DllImport("acr122.dll")]
        public static extern int ACR122_PowerOffIcc(int phReader, int slotNum);

        [DllImport("acr122.dll")]
        public static extern int ACR122_ExchangeApdu(int phReader, int slotNum, ref byte SendBuff, int SendBuffLen,
                                                     ref byte RecvBuff, ref int RecvBuffLen);

        [DllImport("acr122.dll")]
        public static extern int ACR122_PowerOnIcc(int phReader, int slotNum, byte[] atr, ref int pAtrLen);

        [DllImport("acr122.dll")]
        public static extern int ACR122_ExchangeApdu(int phReader, int slotNum, byte[] SendBuff, int SendBuffLen,
                                                     byte[] RecvBuff, ref int RecvBuffLen);

        [DllImport("acr122.dll")]
        public static extern int ACR122_SetLedStates(int phReader, int[] states, int numstates);

        [DllImport("acr122.dll")]
        public static extern int ACR122_DisplayLcdMessageA(int phReader, int row, int col, string message);

        [DllImport("acr122.dll")]
        public static extern int ACR122_DisplayLcdMessageExA(int phReader, int row, int col, int tableIndex,
                                                             int boldMode, string message);

        [DllImport("acr122.dll")]
        public static extern int ACR122_DisplayLcdMessageGBA(int phReader, int row, int col, int boldMode,
                                                             string message);

        [DllImport("acr122.dll")]
        public static extern int ACR122_ClearLcd(int phReader);

        [DllImport("acr122.dll")]
        public static extern int ACR122_EnableLcdBacklight(int phReader, bool enabled);

        [DllImport("acr122.dll")]
        public static extern int ACR122_EnableLed(int phReader, bool enabled);

        [DllImport("acr122.dll")]
        public static extern int ACR122_PauseLcdScrolling(int phReader);

        [DllImport("acr122.dll")]
        public static extern int ACR122_StopLcdScrolling(int phReader);

        [DllImport("acr122.dll")]
        public static extern int ACR122_SetLcdContrast(int phReader, int level);

        [DllImport("acr122.dll")]
        public static extern int ACR122_StartLcdScrolling(int phReader, int row, int col, int HRange, int VRange,
                                                          int Speed, int Direction);

        [DllImport("acr122.dll")]
        public static extern int ACR122_DrawLcd(int phReader, int lineIndex, byte[] pixelBuffer, int pixelBufferLen);

        [DllImport("acr122.dll")]
        public static extern int ACR122_Beep(int phReader, int buzzerOnDuration, int buzzerOffDuration, int numTimes);

        #endregion

    }


}
